<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="../static/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../static/css/main.css"/>
    <link rel="shortcut icon" href="../resources/favicon.ico" th:href="@{/static/favicon.ico}"/>


    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <style>
        th {
            text-align: center;
        }

        .main-wrap {
            margin-left: 0;
        }
    </style>
</head>
<body>
<script>
    $(function () {
        $("#class_num").click(function () {
            $("#table").empty()
            var class_name = $("#class_num").val();
            var teacher_name = $("#teacher_name").val();
            $.ajax({
                url: "../teacher/selectAssignment3",
                data: {
                    class_name: class_name,
                    teacher_name: teacher_name
                },
                success: function (data) {
                    for (x in data) {
                        var tr1 = $("<tr></tr>")
                        var tr2 = $("<tr></tr>")
                        var content = $(' <th>' + '任务内容' + '</th>')
                        var student = $(' <th>' + '学生' + '</th>')
                        var status = $(' <th>' + '状态' + '</th>')
                        var cao = $(' <th>' + '操作' + '</th>')
                        var getassid = $('<td hidden id="getassid" align="center">' + data[x].ass_id + ' </td>')
                        var gettaskid = $('<td hidden id="getassid" align="center">' + data[x].ass_task_id + ' </td>')
                        var ass_content = $('<td align="center">' + data[x].ass_content + '</td>');
                        var ass_student = $('<td align="center">' + data[x].ass_student + '</td>');
                        if (data[x].ass_status==1) {
                            var ass_status = $('<td align="center">' + '已批阅' + '</td>');
                        }
                        if (data[x].ass_status==0) {
                            var ass_status = $('<td align="center">' + '未批阅' + '</td>');
                        }

                        var caozuo = $('<td align="center">' + '<a id="bianji" href="/teacher/correcthomework?ass_id=' + data[x].ass_id + '">查看</a>' + '</td>');
                        tr1.append(content).append(student).append(status).append(cao);
                        tr2.append(getassid).append(gettaskid).append(ass_content).append(ass_student).append(ass_status).append(caozuo);
                        $('#table').append(tr1).append(tr2);
                    }
                }
            })
        })
    })

</script>
<div class="main-wrap">
    <div class="search-wrap">
        <div class="search-content">
            <select id="class_num">
                <option value="0" selected>请选择班级</option>
                <option value="计一">计一</option>
                <option value="软一">软一</option>
                <option value="软二">软二</option>
                <option value="软三">软三</option>
            </select>
        </div>
        <input type="hidden" id="teacher_name" th:value="${session.teacher.getT_name()}">
    </div>
    <div class="result-wrap">
        <form name="myform" id="myform">
            <div class="result-content">
                <table class="result-tab" width="100%" id="table" style="table-layout: fixed;">
                    <tr>
                        <th>任务内容</th>
                        <th>学生</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>

                </table>
            </div>
        </form>
    </div>
</div>
</body>
</html>